/*
 *Copyright (c) 2024 Black Sesame Technologies
 *
 *Licensed under the Apache License, Version 2.0 (the "License");
 *you may not use this file except in compliance with the License.
 *You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 *Unless required by applicable law or agreed to in writing, software
 *distributed under the License is distributed on an "AS IS" BASIS,
 *WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *See the License for the specific language governing permissions and
 *limitations under the License.
*/

#ifndef BASE_TYPES_H
#define BASE_TYPES_H
#include "Std_Types.h"
#include "Compiler.h"
#include "utility_lite.h"

/*==================================================================================================
*                                       DEFINES AND MACROS
==================================================================================================*/
#ifndef NULL
  #define NULL   0
#endif

#ifndef _SIZE_T
#define _SIZE_T
typedef unsigned int size_t;
#endif  /* _SIZE_T */

typedef signed long long int          s64;
typedef signed long                   s32;
typedef signed short                  s16;
typedef char                          s8;

typedef unsigned long long int        u64;
typedef unsigned long                 u32;
typedef unsigned short                u16;
typedef unsigned char                 u8;

#if (!defined(MIN_VAL))
	#define MIN_VAL( X, Y )  ((X) < (Y) ? (X) : (Y))
#endif

#if (!defined(INT_MAX))
	#define INT_MAX		((int)(~0U>>1))
#endif

#if (!defined(INT_MIN))
	#define INT_MIN		(-INT_MAX - 1)
#endif

#if (!defined(UINT_MAX))
	#define UINT_MAX	(~0U)
#endif

#if (!defined(LONG_MAX))
	#define LONG_MAX	((long)(~0UL>>1))
#endif

#if (!defined(LONG_MIN))
	#define LONG_MIN	(-LONG_MAX - 1)
#endif

#if (!defined(ULONG_MAX))
	#define ULONG_MAX	(~0UL)
#endif

#define max(a, b)        ((a) > (b) ? (a) : (b))
#define min(a, b)        ((a) < (b) ? (a) : (b))

#define min3(x, y, z) min(min(x, y), z)
#define max3(x, y, z) max(max(x, y), z)

/**
 * ARRAY_SIZE - get the number of elements in array @arr
 * @arr: array to be sized
 */
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

#endif
